# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-camlzip
_pkgname=camlzip
pkgver=1.11
_pkgver="rel${pkgver//./}"
pkgrel=1
pkgdesc="Access compressed files in ZIP, GZIP and JAR format"
url="https://github.com/xavierleroy/camlzip"
arch="all !riscv64"  # limited by ocaml aport
license="LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="ocaml ocaml-findlib zlib-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/xavierleroy/camlzip/archive/$_pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$_pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	make all
}

package() {
	export OCAMLFIND_DESTDIR="$pkgdir/$_ocamldir"
	export OCAMLFIND_LDCONF=ignore
	mkdir -vp "$OCAMLFIND_DESTDIR"

	make install
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
4d69ef900437e66e00cd345497ec70f407f28cd8344ee5f2fad685d3bfe356924597d1854b752f2841b4007f96d6e0307cfae7e13cfb6f74951ae3eba5198a06  ocaml-camlzip-1.11.tar.gz
"
